package com.xb.loan.fund.service.bean;


import com.xb.loan.fund.service.IFundService;
import com.xb.loan.fund.service.constant.FundConst;

import java.util.HashMap;
import java.util.Map;


public class ChargeResultVO extends AbstractCashierResult {
	private static final long serialVersionUID = -4711936644645759334L;
	/**充值渠道类型 */
	private int payChannelType;
	
	/**充值订单ID*/
	private String chargeId;
	
	private Integer payCardType;//支付卡类型（选填）
	
	private String payCardNo;//支付卡号码（选填）
	
	private String payCardName;//支付卡户名（选填）
	/**
	 * 根据returnCode返回码，获取真正的返回结果
	 * @return
	 * 2015年9月7日 by zhangyi
	 */
	public int generateResult(){
		Map<String,Integer> map = new HashMap<String,Integer>();
		
		map.put("1", FundConst.ChargeStatus_Success);
		map.put("2", FundConst.ChargeStatus_Fail);
		if(this.getReturnCode() == null || !map.containsKey(this.getReturnCode())){
			throw new RuntimeException("收银台充值结果状态不正确：" + this.getReturnCode());
		}
		return map.get(this.getReturnCode());
	}
	
	public static void main(String[] args){
		new ChargeResultVO().generateResult();
	}
	
	/**
	 * 
	 *  生成秘钥的顺序   充值订单ID+充值平台ID+充值用户ID+渠道ID +充值金额+充值结果
	 * @return
	 * 2015年9月7日 by zhangyi
	 */
	public String generateKey(){
		StringBuffer sb = new StringBuffer();
		String strCentor = FundConst.Encrypt_Field_Splitter;
		sb.append(getChargeId());
		sb.append(strCentor);
		sb.append(getPlatId());
		sb.append(strCentor);
		sb.append(getUserId());
		sb.append(strCentor);
		sb.append(IFundService.df.format(getMoney()));
		sb.append(strCentor);
		sb.append(getReturnCode());
		
		return sb.toString();
	}
	
	public int getPayChannelType() {
		return payChannelType;
	}
	public void setPayChannelType(int payChannelType) {
		this.payChannelType = payChannelType;
	}
	public String getChargeId() {
		return chargeId;
	}
	public void setChargeId(String chargeId) {
		this.chargeId = chargeId;
	}
	public Integer getPayCardType() {
		return payCardType;
	}
	public void setPayCardType(Integer payCardType) {
		this.payCardType = payCardType;
	}
	public String getPayCardNo() {
		return payCardNo;
	}
	public void setPayCardNo(String payCardNo) {
		this.payCardNo = payCardNo;
	}
	public String getPayCardName() {
		return payCardName;
	}
	public void setPayCardName(String payCardName) {
		this.payCardName = payCardName;
	}
	
	@Override
	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append("\tchargeId = ").append(this.getChargeId())
			.append("\tforeignId = ").append(this.getForeignId())
			.append("\tuserId = ").append(this.getUserId())
			.append("\tplatId = ").append(this.getPlatId())
			.append("\tmoney = ").append(this.getMoney())
			.append("\treturnCode = ").append(this.getReturnCode())
			.append("\tdigitalSign = ").append(this.getDigitalSign())
			.append("\tpayChannelType = ").append(this.getPayChannelType())
			.append("\tpaycardType = ").append(this.getPayCardType())
			.append("\tpaycardName = ").append(this.getPayCardName())
			.append("\tpaycardNo = ").append(this.getPayCardNo());
		return buf.toString();
	}
	
}
